Repository navigation
media: add bounded PCM playout and artifact-based NetEq comparisons - #8823
Merged
Merged
Conversation
theomonnom
force-pushed
the
codex/media-stream-playout
branch
from
November 28, 2026 03:16
d155da2 to
7e1b936
Compare
theomonnom
marked this pull request as ready for review
November 28, 2026 08:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Provider PCM arriving after an empty playback queue causes gaps and abrupt returns. Add bounded, synchronous playout in the media crate: adaptive reserve, pitch-preserving time scaling, mixed concealment, learned room tone and recovery merging.
Native mono 16/24/48 kHz PCM16, selected once in
Config::sample_rate(default 24 kHz). Arbitrary chunks; render 1 sample through 20 ms.Playout::continuous(config)needs no boundaries and exposesfinish().Playout::segmented(config)exposesbegin_segment()/end_segment()and retains normalized delivery timing. Distinct types share the same DSP and buffers.NetEq-aligned processing: 30 ms time-scale window, whole-period crossfade, 0.9/0.5 normal/fast correlation, about 50 ms ordinary spacing and emergency acceleration above four times the high-delay threshold. The 3% quota/profile is removed. Current relative playout delay drives decisions directly, as in NetEq; no extra smoothing gate delays catch-up. Keep the provider-specific startup protection: configurable 80 ms cold hold, protected early reserve, burst/EOF release and learned segment startup. Default target remains 20–100 ms; queue capacity 2 s.
Listen
Same captured GPTLive speech (marin), gain and ordered source per row. Start/Slow: 3 s; others: 6 s. Common wall-clock crops preserve initial wait. Links show measured added startup delay (1 ms signal-onset analysis), excluding model, live network and device latency. Minimal 32×32 MP4 attachments; no media binaries or attachment/plot generation scripts are committed.
late-start-untreated.mp4
late-start-neteq.mp4
late-start-rust.mp4
slow-start-untreated.mp4
slow-start-neteq.mp4
slow-start-rust.mp4
slow-jitter-untreated.mp4
slow-jitter-neteq.mp4
slow-jitter-rust.mp4
repeated-stalls-untreated.mp4
repeated-stalls-neteq.mp4
repeated-stalls-rust.mp4
stall-1s-untreated.mp4
stall-1s-neteq.mp4
stall-1s-rust.mp4
catch-up-untreated.mp4
catch-up-neteq.mp4
catch-up-rust.mp4
Start: second chunk 60 ms late. Slow: first 400 ms delivered at 1.8× the nominal interval, accumulating 320 ms lag. Jitter: 20 s of 1%-slow delivery plus 0–30 ms jitter. Stalls: four 80 ms pacing pauses with retained delay. Outage: 1 s pause. Catchup: 1.5 s of source at 3× speed. Synthetic, report-inspired stress cases; not customer trace replays.
Learning across answers
Answer 2 after one training answer. Identical source, arrivals, DSP and settings; only timing retention changes. Both use a 20 ms cold prior and an explicit 400 ms maximum, with the Slow schedule above. First-answer controls are byte-identical; duplicate listening links are omitted.
learn-reset.mp4
learn-retained.mp4
Cost: +320 ms startup, avoiding 290.4 ms of concealment in this replay. This is not the default 100 ms cap. With clean segment arrivals, the default startup hold relaxes 80 → 60 → 40 → 20 ms; recent bad history can keep it elevated longer.
Timing
Catch-up queued audio at 20 s: Rust 190 ms / NetEq 196 ms. Both queue counters include pending output. The plot shows 100 ms means with faint min/max ranges; the quoted 20 s values are raw samples. Queues need not be identical: startup protection, chunk-aware arrival estimates and independent DSP remain different. The native reference keeps its own unlimited target maximum; the script supports an explicit alternative cap.
Validation
238 Rust runtime tests + 2 API compile-fail tests pass, one existing ignored. External audit checks verified off-grid stalls, valid short controls/startup, and incomplete repeated-stall schedules. An additional 288 seeded stress cases pass across all rates, capacities, irregular render sizes, overflow atomicity, drain/reset and long clock epochs. Coverage includes native-rate pitch/energy/recovery, clean PCM preservation, startup learning, continuous silence/resumption, cadence/emergency catch-up, exact source accounting, atomic errors, EOF and zero allocations on the audio path. Purity-policy Clippy, formatting, strict mypy, Ruff and architecture checks pass.
All seven posted Devin findings were reproduced and addressed. Quiet splice preference is shared across search paths; local seam checks are shared by normal and history-based time scaling, accept identical clipped plateaus and reject unequal flat windows. Startup replay schedules require an actual resumed nominal interval. External checks cover 36 startup recovery boundaries across rates and chunk sizes. Immutable schedules own actual chunk-boundary fault events, validate complete source/event coverage before compilation, and supply both injection timing and report labels. Concurrent comparison builds have distinct runner names. The comparison script contains no embedded tests. Fresh replays across all three rates reproduce all 360 existing audio/trace files byte-for-byte after the latest review fixes.
All 12 presets × 3 rates rendered against pinned actual NetEq. Only the reference converts to/from 48 kHz for L16, retaining each enclosing chunk's arrival time. The standalone
neteq_compare.pyrecords settings, seed, hashes, queues, operation traces and pre-EOF counters; fixed inputs/toolchain make retries deterministic.The rate-only change (
2bb44b7ca5) preserved all previous 24 kHz PCM and traces byte-for-byte. The subsequent explicit cadence/splice tuning intentionally changes playback; the current deterministic PCM golden pins that latest behavior. API and comparison usage.This is not enabled in live sessions. Provider/runtime wiring and broader listening review remain; matching features and timing does not establish perceptual parity.